package com.itheima.controller;


import com.itheima.common.MenusResult;
import com.itheima.common.Point;
import com.itheima.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menus")
public class MenusController {
    @Autowired
    private PermissionService permissionService;

    //菜单列表
    @GetMapping
    private List<MenusResult> menusList() {
        List<MenusResult> resultList = permissionService.findList();
        return resultList;
    }

    //菜单详情
    @GetMapping("/{id}")
    public Point findMenus(@PathVariable Long id) {
       Point point = permissionService.findMenus(id);
       return point;
    }

    //菜单修改
    @PutMapping("/{id}")
    public void modifyMenus(@PathVariable Long id,@RequestBody Point point){
        permissionService.modify(id,point);
    }

    //菜单添加
    @PostMapping
    public void addMenus(@RequestBody Point point){
        permissionService.insert(point);
    }

    //菜单删除
    @DeleteMapping("/{id}")
    public void removeById(@PathVariable Long id){
        permissionService.remove(id);
    }
}
